} bounds;
typedef struct {
- int request_terminate;
+ volatile int request_terminate;
} posn_status;
-
+extern posn_status tracking_status;
typedef void (*ff_init) (char const *);
typedef void (*ff_deinit) (void);
time_t gpsbabel_now; /* gpsbabel startup-time; initialized in main.c with time() */
time_t gpsbabel_time; /* gpsbabel startup-time; initialized in main.c with current_time(), ! ZERO within testo ! */
+posn_status tracking_status;
* matters in this mode, turn the pretty formatting off.
*/
do_indentation = 0;
- kml_wr_init(posnfilenametmp);
max_position_points = atoi(opt_max_position_points);
}
MOVEFILE_REPLACE_EXISTING);
#endif
rename(posnfilenametmp, posnfilename);
+ }
+ ofd = NULL;
+}
+
+static void
+kml_wr_position_deinit(void)
+{
+ kml_wr_deinit();
+ if (posnfilenametmp) {
xfree(posnfilenametmp);
posnfilenametmp = NULL;
}
- ofd = NULL;
}
/*
{
static time_t last_valid_fix;
+ kml_wr_init(posnfilenametmp);
+
if (!posn_trk_head) {
posn_trk_head = route_head_alloc();
track_add_head(posn_trk_head);
waypoint *tonuke = (waypoint *) QUEUE_FIRST(&posn_trk_head->waypoint_list);
track_del_wpt(posn_trk_head, tonuke);
}
+
+// kml_wr_deinit();
}
ff_vecs_t kml_vecs = {
NULL,
kml_args,
CET_CHARSET_UTF8, 1, /* CET-REVIEW */
- { NULL, NULL, NULL, kml_wr_position_init, kml_wr_position, kml_wr_deinit }
+ { NULL, NULL, NULL, kml_wr_position_init, kml_wr_position, kml_wr_position_deinit }
};
#include "csv_util.h"
#include "inifile.h"
#include <ctype.h>
+#include <signal.h>
#define MYNAME "main"
+void signal_handler(int sig);
+
typedef struct arg_stack_s {
int argn;
int argc;
" -s Synthesize shortnames\n"
" -r Process route information\n"
" -t Process track information\n"
+" -T Process realtime tracking information\n"
" -w Process waypoint information [default]\n"
" -b Process command file (batch mode)\n"
" -c Character set for next operation\n"
ivecs->rd_init(fname);
ivecs->read();
ivecs->rd_deinit();
-
+
cet_convert_strings(global_opts.charset, NULL, NULL);
cet_convert_deinit();
}
if (ovecs) {
- if (!ovecs->position_ops.wr_init ||
- !ovecs->position_ops.wr_position ||
- !ovecs->position_ops.wr_deinit) {
- fatal ("This output format does not support realtime positioning.\n");
+ if ( !ovecs->position_ops.wr_position ) {
+ fatal ("This output format does not support output of realtime positioning.\n");
}
}
- while (1) {
- posn_status status;
+ if (signal(SIGINT, signal_handler) == SIG_ERR) {
+ fatal ("Couldn't install the exit signal handler.\n");
+ }
+
+ if (ovecs->position_ops.wr_init) {
+ ovecs->position_ops.wr_init(ofname);
+ }
+
+ tracking_status.request_terminate = 0;
+ while (!tracking_status.request_terminate) {
waypoint *wpt;
- status.request_terminate = 0;
- wpt = ivecs->position_ops.rd_position(&status);
+ tracking_status.request_terminate = 0;
+ wpt = ivecs->position_ops.rd_position(&tracking_status);
- if (status.request_terminate) {
+ if (tracking_status.request_terminate) {
if (wpt) {
waypt_free(wpt);
}
}
if (wpt) {
if (ovecs) {
- ovecs->position_ops.wr_init(ofname);
+// ovecs->position_ops.wr_init(ofname);
ovecs->position_ops.wr_position(wpt);
- ovecs->position_ops.wr_deinit();
+// ovecs->position_ops.wr_deinit();
} else {
/* Just print to screen */
waypt_disp(wpt);
#endif
exit(0);
}
+
+void signal_handler(int sig)
+{
+ tracking_status.request_terminate = 1;
+}
+
static char *getposnarg = NULL;
static char *opt_sleep = NULL;
static char *opt_baud = NULL;
+static char *opt_append = NULL;
static long sleepus = 0;
static int getposn;
+static int append_output;
static time_t last_time = -1;
static double last_read_time; /* Last timestamp of GGA or PRMC */
{ "get_posn", &getposnarg, "Return current position as a waypoint",
NULL, ARGTYPE_BOOL, ARG_NOMINMAX},
{"pause", &opt_sleep, "Decimal seconds to pause between groups of strings", NULL, ARGTYPE_INT, ARG_NOMINMAX },
+ {"append_positioning", &opt_append, "Append realtime positioning data to the output file instead of truncating", "0", ARGTYPE_BOOL, ARG_NOMINMAX },
{"baud", &opt_baud, "Speed in bits per second of serial port (baud=4800)", NULL, ARGTYPE_INT, ARG_NOMINMAX },
ARG_TERMINATOR
};
static void
nmea_wr_init(const char *portname)
{
- file_out = gbfopen(portname, "w+", MYNAME);
+ append_output = atoi(opt_append);
+
+ file_out = gbfopen(portname, append_output ? "a+" : "w+", MYNAME);
if ( opt_sleep ) {
if ( *opt_sleep ) {
sleepus = -1;
}
}
-
+
mkshort_handle = mkshort_new_handle();
setshort_length(mkshort_handle, atoi(snlenopt));
}
track_disp_all(nmea_track_init, NULL, nmea_trackpt_pr);
}
+static void
+nmea_wr_posn_init(const char *fname)
+{
+ nmea_wr_init(fname);
+}
+
+static void
+nmea_wr_posn(waypoint *wpt)
+{
+ nmea_trackpt_pr(wpt);
+}
+
+static void
+nmea_wr_posn_deinit(void)
+{
+// nmea_wr_deinit();
+}
+
+
ff_vecs_t nmea_vecs = {
ff_type_file,
{ ff_cap_read | ff_cap_write, ff_cap_read | ff_cap_write, ff_cap_none},
NULL,
nmea_args,
CET_CHARSET_ASCII, 0, /* CET-REVIEW */
- { nmea_rd_posn_init, nmea_rd_posn, nmea_rd_deinit, NULL, NULL, NULL }
+ { nmea_rd_posn_init, nmea_rd_posn, nmea_rd_deinit,
+ nmea_wr_posn_init, nmea_wr_posn, nmea_wr_posn_deinit }
};
/*